﻿using UnityEngine;
using System.Collections;

public class SimpleFollow : MonoBehaviour {

	public Transform target;
	public Vector3 distanceFromTarget = new Vector3(0,0,-10);

	public Vector3 gotoPosition;
	public float ease = 0.7f;
	public float easeCamRot = 2;
	private Quaternion originalRot;

	void FixedUpdate () 
	{
		if (target == null) return;
		gotoPosition = target.position + distanceFromTarget;

		transform.position = Vector3.Lerp (transform.position, 
		                                  gotoPosition, 
		                                  Time.deltaTime * ease);

		originalRot = transform.rotation;
		transform.LookAt (target);
		transform.rotation = 
			Quaternion.Lerp (originalRot, 
			                 transform.rotation, 
			                 Time.deltaTime * easeCamRot);
	}
}
